package entities.reports;

import entities.forum.Message;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * Trabalho PD - 2014/2015
 * @author a21210380 a21210392
 */
@Entity
@Table(name = "reported_message")
@NamedQueries({
    @NamedQuery(name = "ReportedMessage.findAll", query = "SELECT r FROM ReportedMessage r"),
    @NamedQuery(name = "ReportedMessage.findByIdReportedMessage", query = "SELECT r FROM ReportedMessage r WHERE r.idReportedMessage = :idReportedMessage"),
    @NamedQuery(name = "ReportedMessage.findByReason", query = "SELECT r FROM ReportedMessage r WHERE r.reason = :reason"),
    @NamedQuery(name = "ReportedMessage.findByReportedDate", query = "SELECT r FROM ReportedMessage r WHERE r.reportedDate = :reportedDate")})
public class ReportedMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idReportedMessage")
    private Integer idReportedMessage;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "reason")
    private String reason;
    @Basic(optional = false)
    @NotNull
    @Column(name = "reportedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date reportedDate;
    @JoinColumn(name = "idMessage", referencedColumnName = "idMessage")
    @ManyToOne(optional = false)
    private Message idMessage;

    public ReportedMessage() {
    }

    public ReportedMessage(Integer idReportedMessage) {
        this.idReportedMessage = idReportedMessage;
    }

    public ReportedMessage(Integer idReportedMessage, String reason, Date reportedDate) {
        this.idReportedMessage = idReportedMessage;
        this.reason = reason;
        this.reportedDate = reportedDate;
    }

    public Integer getIdReportedMessage() {
        return idReportedMessage;
    }

    public void setIdReportedMessage(Integer idReportedMessage) {
        this.idReportedMessage = idReportedMessage;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Date getReportedDate() {
        return reportedDate;
    }

    public void setReportedDate(Date reportedDate) {
        this.reportedDate = reportedDate;
    }

    public Message getIdMessage() {
        return idMessage;
    }

    public void setIdMessage(Message idMessage) {
        this.idMessage = idMessage;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idReportedMessage != null ? idReportedMessage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ReportedMessage)) {
            return false;
        }
        ReportedMessage other = (ReportedMessage) object;
        if ((this.idReportedMessage == null && other.idReportedMessage != null) || (this.idReportedMessage != null && !this.idReportedMessage.equals(other.idReportedMessage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.extra.ReportedMessage[ idReportedMessage=" + idReportedMessage + " ]";
    }

}
